// 状态即是数据
const state = {
    isLoading: false
};

// 处理状态的改变
const mutations = {
    openLoading: function (state) {
        state.isLoading = true;
    },
    closeLoading: function (state) {
        state.isLoading = false;
    }
};

// 定义getters 读取状态
const getters = {
    getLoading(state) {
        return state.isLoading;
    }
};

// 定义action,要执行的操作，如流程判断，异步请求等
const actions = {
    loadingStart({ commit }) {
        commit("openLoading");
    },
    loadingEnd({ commit }) {
        commit("closeLoading");
    }
}

export default {
    state,
    mutations,
    getters,
    actions
}
